<?php
////////////////////////////////////////////////////////////////////////////////
//	  This file is part of PushLMS.
//
//    PushLMS is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    PushLMS is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with PushLMS.  If not, see <http://www.gnu.org/licenses/>.
//
///////////////////////////////////////////////////////////////////////////////
	
class Answer extends AppModel {

	var $name = 'Answer';

	var $displayField  = 'answer_text';

	var $belongsTo = array(
		'Question',
	);

	var $hasMany = array(
		'Asessionresult',
	);

	var $validate = array(
	
		'answer_text' => array(
			'notEmpty' => array(
				'rule' => 'notEmpty',
				'message' => 'Answer Text cannot be blank.'
			),
		),

		'answer_int' => array(
			'notEmpty' => array(
				'rule' => 'notEmpty',
				'message' => 'Answer Int cannot be blank.'
			),
			'numeric' => array(
				'rule' => 'numeric',  
				'message' => 'Answer Int must be a number.'
			)

		),
		
		'deducted_mark' => array
		(
			'notEmpty' => array
			(
				'rule' => 'notEmpty',
				'message' => 'Deducted score cannot be blank.'
			),
			'numeric' => array
			(
				'rule' => 'numeric',  
				'message' => 'Deducted score must be a number.'
			),
			'max' => array
			(        
				'rule' => array
				(
					'comparison', 'less or equal', 100
				),        
				'message' => 'Deducted score must be between 0 and 100'    
			),
			'min' => array
			(        
				'rule' => array
				(
					'comparison', 'greater or equal', 0
				),        
				'message' => 'Deducted score must be between 0 and 100'    
			)
		),

	);


}
?>